<template>
  <div class="tables-page" v-loading="thisLoading">
    <header class="search-header">
      <el-form size="small" :inline="true" :model="formInline" class="demo-form-inline">
        <el-form-item label="审批人">
          <el-input v-model="formInline.user" placeholder="审批人"></el-input>
        </el-form-item>
        <el-form-item label="活动区域">
          <el-select v-model="formInline.region" placeholder="活动区域">
            <el-option label="区域一" value="shanghai"></el-option>
            <el-option label="区域二" value="beijing"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item>
          <el-button type="primary">查询</el-button>
        </el-form-item>
      </el-form>
    </header>
    <el-table :border="true" :data="tableData" size="small">
      <el-table-column prop="userName" label="姓名" width="180"></el-table-column>
      <el-table-column prop="_id" label="ID"></el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
          <el-button size="mini" type="danger" @click="handleDelete(scope.$index, scope.row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <div class="total-box">
      <paginationTable :total="total" :currentPage="currentPage" :pagesize="pagesize"></paginationTable>
    </div>
  </div>
</template>
<script>
import { getUserDatas } from "@/api/getData";
import PaginationTable from "@/components/public/paginationTable";
export default {
  name: "Tables",
  components: {
    paginationTable: PaginationTable
  },
  data() {
    return {
      tableData: [],
      total: 0,
      currentPage: 1,
      pagesize: 10,
      formInline: {
        user: "",
        region: ""
      }
    };
  },
  computed: {
    thisLoading() {
      return this.$store.state.isLoading;
    }
  },
  mounted() {
    this.initData();
  },
  methods: {
    async initData() {
      this.$store.dispatch("changeLoading", true);
      try {
        const data = await getUserDatas();
        const res = data.data
        this.tableData = res.res;
        this.total = res.totle;
        this.$store.dispatch("changeLoading", false);
      } catch (error) {
        console.log(error);
      }
    },
    handleEdit() {},
    handleDelete() {}
  }
};
</script>
<style lang="less" scoped>
@import url("./less/index.less");
</style>